package logic

import (
	"bw-renting/house-rpc/house"
	"context"

	"bw-renting/api/internal/svc"
	"bw-renting/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CreateHouseFacilityLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCreateHouseFacilityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateHouseFacilityLogic {
	return &CreateHouseFacilityLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// TODO: 添加房屋设施
func (l *CreateHouseFacilityLogic) CreateHouseFacility(req *types.CreateHouseFacilityReq) (resp *types.Data, err error) {
	// todo: add your logic here and delete this line
	res, _ := l.svcCtx.HouseServer.CreateHouseFacility(context.Background(), &house.CreateHouseFacilityReq{
		HouseId:    int64(req.HouseId),
		FacilityId: int64(req.FacilityId),
	})
	if res.Status == "0" {
		return &types.Data{
			Code:    10001,
			Message: "添加房屋设施失败",
			Data:    nil,
		}, nil
	}
	return &types.Data{
		Code:    200,
		Message: "添加房屋设施成功",
		Data:    nil,
	}, nil
}
